package cn.scm.server.multistage.service.impl;

import cn.scm.server.multistage.dao.BizCreditGrantingRecordDao;
import cn.scm.server.multistage.entity.BizCreditGrantingRecord;
import cn.scm.server.multistage.service.BizCreditGrantingRecordService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 授信记录表(BizCreditGrantingRecord)表服务实现类
 *
 * @author makejava
 * @since 2020-09-23 20:51:24
 */
@Service("bizCreditGrantingRecordService")
public class BizCreditGrantingRecordServiceImpl implements BizCreditGrantingRecordService {
    @Resource
    private BizCreditGrantingRecordDao bizCreditGrantingRecordDao;

    /**
     * 通过ID查询单条数据
     *
     * @param creditGrantingId 主键
     * @return 实例对象
     */
    @Override
    public BizCreditGrantingRecord queryById(String creditGrantingId) {
        return this.bizCreditGrantingRecordDao.queryById(creditGrantingId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<BizCreditGrantingRecord> queryAllByLimit(int offset, int limit) {
        return this.bizCreditGrantingRecordDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param bizCreditGrantingRecord 实例对象
     * @return 实例对象
     */
    @Override
    public BizCreditGrantingRecord insert(BizCreditGrantingRecord bizCreditGrantingRecord) {
        this.bizCreditGrantingRecordDao.insert(bizCreditGrantingRecord);
        return bizCreditGrantingRecord;
    }

    /**
     * 修改数据
     *
     * @param bizCreditGrantingRecord 实例对象
     * @return 实例对象
     */
    @Override
    public BizCreditGrantingRecord update(BizCreditGrantingRecord bizCreditGrantingRecord) {
        this.bizCreditGrantingRecordDao.update(bizCreditGrantingRecord);
        return this.queryById(bizCreditGrantingRecord.getCreditGrantingId());
    }

    /**
     * 通过主键删除数据
     *
     * @param creditGrantingId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String creditGrantingId) {
        return this.bizCreditGrantingRecordDao.deleteById(creditGrantingId) > 0;
    }
}